package cn.tedu;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Classname: Demo04
 * @Author: bromide
 * @CreateTime: 2022/5/9--17:23
 * @Version: V1.0
 * @Description:
 */
public class Demo04 {
    public static void main(String[] args) {
        //从工具类中获取链接对象
        try(Connection conn = DBUtils.getConn()) {

            //创建执行SQL语句的对象
            Statement s = conn.createStatement();
            //执行查询
            ResultSet rs = s.executeQuery("select name from emp");
            while(rs.next()){
                String name = rs.getString(1);
                System.out.println(name);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
